export default class {
  private options = {
    params: {} as { [key: string]: any },
    data: {} as { [key: string]: any } | FormData,
    headers: {} as { [key: string]: any },
    urlParams: {} as { [key: string]: any },
  };
  constructor() {

  }
  public getUrlParams() {
    return this.options.urlParams;
  }
  public setUrlParams(obj: { [key: string]: any }) {
    this.options.urlParams = Object.assign({}, this.options.urlParams, obj);
  }
  public removeUrlParam(key: string) {
    delete this.options.urlParams[key];
  }
  public getParams() {
    return this.options.params;
  }
  public getParam(key: string) {
    return this.options.params[key];
  }
  public setParams(obj: { [key: string]: any }) {
    this.options.params = Object.assign({}, this.options.params, obj);
  }
  public removeParam(key: string) {
    delete this.options.params[key];
  }
  public getHeaders() {
    return this.options.headers;
  }
  public getHeader(key: string) {
    return this.options.headers[key];
  }
  public setHeaders(obj: { [key: string]: any }) {
    this.options.headers = Object.assign({}, this.options.headers, obj);
  }
  public removeHeader(key: string) {
    delete this.options.headers[key];
  }
  public getDatas() {
    return this.options.data;
  }
  public getData(key: string) {
    if (this.options.data instanceof FormData) {
      return this.options.data.get(key);
    } else {
      return this.options.data[key];
    }
  }
  public setDatas(obj: { [key: string]: any } | any[]) {
    if (obj instanceof Array) {
      this.options.data = obj;
    } else {
      this.options.data = Object.assign({}, this.options.data, obj);
    }

  }
  public setFormData(obj: { [key: string]: any }) {
    if (!(this.options.data instanceof FormData)) {
      this.options.data = new FormData();
    }
    Object.entries(obj).forEach(x => {
      this.options.data.set(x[0], x[1]);
    })
  }
  public getOptions() {
    return this.options;
  }
}